<?php Yii::app()->clientScript->registerScriptFile(Helper::getUrl('js/tiny_mce/tiny_mce.js'))?>
<script type="text/javascript">
    tinyMCE.init({
		// General options
		mode : "textareas",
		theme : "advanced",
		plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,syntaxhl",
//		plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,insertCode,syntaxHighlighter,uploadImage,insertMusic",
//		plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,insertCode,syntaxHighlighter,uploadImage,insertMusic",

		// Theme options
		theme_advanced_buttons1 : "formatselect,fontselect,fontsizeselect,separator,forecolor,backcolor,separator,bold,italic,underline,strikethrough,separator,bullist,numlist,separator, justifyleft, justifycenter, justifyright,syntaxhl",
		theme_advanced_buttons2 : "undo,redo,cut,copy,paste,separator,justifyleft,justifycenter,justifyright,separator,outdent,indent,removeformat,separator,link,unlink,image,uploadImage,media,insertMusic,separator,insertCode,syntaxHighlighter,separator,code,fullscreen",
		theme_advanced_buttons3 : "",
		theme_advanced_buttons4 : "",
		theme_advanced_resizing : true,
		theme_advanced_resize_horizontal : false,
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_fonts:"宋体=宋体;黑体=黑体;仿宋=仿宋;楷体=楷体;隶书=隶书;幼圆=幼圆; Arial=arial,helvetica,sans-serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats",
		font_size_style_values : "8pt,10pt,12pt,14pt,18pt,24pt,36pt",
		convert_fonts_to_spans:true,
		remove_trailing_nbsp:true,
		convert_newlines_to_brs:false,
		force_br_newlines:false,
		force_p_newlines:false,
		remove_linebreaks:false ,
		verify_html:true,
		relative_urls:false,
		remove_script_host: false,
		paste_preprocess: function(pl, o) {
			o.content = o.content.replace(/[\n\r\t]/g, '');
			o.content = o.content.replace(/<br\s\/><br\s\/>/g, '</p><p>');
			o.content = o.content.replace(/<br><br>/g, '</p><p>');
		},
		extended_valid_elements:"pre[name|class],style",
		content_css:"<?php echo Helper::getUrl('css/mce.css')?>",
		//cleanup_callback:"myCustomCleanup",
		handle_event_callback:"MCECheckIndent",
		cleanup : true
	});
		
		function MCECheckIndent(e) {
			if(e.type == 'keydown' && e.keyCode == 9)
			{
			tinyMCE.execCommand('mceInsertContent',false,'　　');
			return false;
			}
		}
		
		function InsertToEditor(content){
			tinyMCE.execCommand('mceInsertContent',false,content);
		} 
</script>
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'post-form',
	'enableAjaxValidation'=>false,
)); ?>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'cid'); ?>
		<?php echo $form->dropDownList($model, 'cid', CHtml::listData($model->categoryData->getData(), 'id', 'name'))?>
		<?php echo $form->error($model,'cid'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'title'); ?>
		<?php echo $form->textField($model,'title',array('maxlength'=>128, 'style' => 'width:100%')); ?>
		<?php echo $form->error($model,'title'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'content'); ?>
		<?php echo $form->textArea($model,'content',array('id' => 'elm1', 'style' => 'height:350px;width:100%')); ?>
		<?php echo $form->error($model,'content'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'tag'); ?>
		<?php echo $form->textField($model,'tag',array('maxlength'=>64, 'style' => 'width:100%')); ?>
		<?php echo $form->error($model,'tag'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->